package ar.edu.unq.wannaplay.utils.buttons;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.form.Form;

import ar.edu.unq.wannaplay.dtos.SkillDTO;
import ar.edu.unq.wannaplay.panels.AbstractEditModelObjectSkillsPanel;

public class AddItemAjaxButton extends ActionOnListAjaxButton {

    private static final long serialVersionUID = 1L;

    public AddItemAjaxButton(final String id,
            final AbstractEditModelObjectSkillsPanel<?, ?> abstractEditModelObjectSkillsPanel) {
        super(id, abstractEditModelObjectSkillsPanel);

    }

    @Override
    protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
        SkillDTO newly = new SkillDTO(this.getPanel().getExperience(), this.getPanel().getKnowledge());
        this.getPanel().getSkillsList().add(newly);
        target.addComponent(this.getPanel().getChoicesList());
    }
}
